{include file="public/head"}
<body>
<div class="x-body">

    <div class="lotus-nav layui-row layui-form-item">
        <button class="layui-btn layui-btn-sm" onclick="x_admin_show('添加菜单','add.html',500)">
            <i class="layui-icon layui-icon-add-circle"></i>
        </button>
        <span class="x-right">共有数据:{:count($auth)}条
            <button onclick="javascript:location.reload()" class="layui-btn-default">
                <i class="icon iconfont">&#xe6aa;</i>
            </button>
        </span>
    </div>

    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>菜单名称</th>
            <th>控制器方法</th>
            <th>图标</th>
            <th>展示</th>
            <th>排序参数(越大越往后)</th>
            <th>状态</th>
            <th>操作</th>
        </thead>
        <tbody>
        {volist name='auth' id='vo'}
        <tr>
            <td>{$i}</td>
            <td>&nbsp;{$vo.level-1|str_repeat='&nbsp;丨---',###}{$vo.title}</td>
            <td>{$vo.name}</td>
            <td>
                <i class="layui-icon">
                    {php}
                    if(empty($vo['icon'])){
                    echo '';
                    }else{
                    echo '&#'.$vo['icon'].';';
                    }
                    {/php}
                </i>
            </td>
            <td>{eq name='vo.status' value='1'}显示{else/}<font color="red">隐藏</font>{/eq}
            </td>
            <td>{$vo.sort}</td>
            <td>{eq name='vo.flag' value='1'}启用{else/}<font color="red">禁用</font>{/eq}
            <td>
                <button type="button" onclick="x_admin_show('编辑菜单', 'edit.html?id={$vo.id}',500)"
                        class="layui-btn layui-btn-xs">编辑
                </button>
                <button type="button" onClick="deleteAuthRule({$vo.id})"
                        class="layui-btn layui-btn-xs layui-btn-danger">删除
                </button>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
</body>
{include file="public/foot"}
<script>
    function deleteAuthRule(id) {
        layer.confirm('确定要删除吗?', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                url: 'delete',
                type: 'post',
                dataType: 'json',
                data: {id: id},
            })
                .done(function (data) {
                    console.log(data);
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 5, time: 500});
                    } else {
                        layer.msg(data.msg, {icon: 1, time: 500}, function () {
                            window.location.reload();
                        })
                    }
                })
        });
    }
</script>
